/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import java.sql.Date;

/**
 * this class represents a Messenger in the database
 * @author gabriellebotbol
 */
public class Messenger implements Serializable
{

    public Messenger(Users user, int idMessenger, String body, int nbLike, int nbUnlike, boolean isPublic, boolean isSystem, Date date) {
        this.user = user;
        this.idMessenger = idMessenger;
        this.body = body;
        this.nbLike = nbLike;
        this.nbUnlike = nbUnlike;
        this.isPublic = isPublic;
        this.isSystem = isSystem;
        this.date = date;
    }
    
    private Messenger() 
    {
    }
        private Users user;

    /**
     * Get the value of user
     *
     * @return the value of user
     */
    public Users getUser() 
    {
        return user;
    }

    
    //idMessenger body nbLike nbUnlike isPublic isSystem
    
    private int idMessenger;

    /**
     * Get the value of idMessenger
     *
     * @return the value of idMessenger
     */
    public int getIdMessenger() 
    {
        return idMessenger;
    }
    
        private String body;

    /**
     * Get the value of body
     *
     * @return the value of body
     */
    public String getBody() {
        return body;
    }
    
        private int nbLike;

    /**
     * Get the value of nbLike
     *
     * @return the value of nbLike
     */
    public int getNbLike() 
    {
        return nbLike;
    }
    
        private int nbUnlike;

    /**
     * Get the value of nbUnlike
     *
     * @return the value of nbUnlike
     */
    public int getNbUnlike() 
    {
        return nbUnlike;
    }

        private boolean isPublic;

    /**
     * Get the value of isPublic
     *
     * @return the value of isPublic
     */
    public boolean getIsPublic() 
    {
        return isPublic;
    }
    
        private boolean isSystem;

    /**
     * Get the value of isSystem
     *
     * @return the value of isSystem
     */
    public boolean getIsSystem() 
    {
        return isSystem;
    }
    private Date date;

    /**
     * Get the value of date
     *
     * @return the value of date
     */
    public Date getDate() 
    {
        return date;
    }

    

    @Override
    public boolean equals(Object obj) 
    {
        if(obj instanceof Messenger)
        {
            return this.hashCode()==obj.hashCode();
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 31 * hash + this.idMessenger;
        hash = 31 * hash + (this.body != null ? this.body.hashCode() : 0);
        hash = 31 * hash + this.nbLike;
        hash = 31 * hash + this.nbUnlike;
        hash = 31 * hash + (this.isPublic ? 1 : 0);
        hash = 31 * hash + (this.user!= null ? this.user.hashCode() : 0);
        return hash;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException 
    {
        Messenger messenger=new Messenger(this.getUser(), this.getIdMessenger(), this.getBody(), this.getNbLike(), this.getNbUnlike(), this.getIsPublic(), this.getIsSystem(), this.getDate());
        return messenger;
    }

    @Override
    public String toString() 
    {
        return "id: "+this.getIdMessenger()+" body: "+this.getBody()+" liked by "+this.getNbLike()+" peoples unliked by: "+this.getNbUnlike()+" peoples public mail: "+this.getIsPublic()+" system mail: "+this.getIsSystem();
    }
    
}
